<include file="Index:header" />
<!-- Content Header (Page header) -->
    <section class="content-header">
      <h1> 轮播图片 </h1>
      <ol class="breadcrumb">
        <li><a href="__APP__/TIFAWEB_DSWJCMS.html" class="goindex"><i class="fa fa-dashboard"></i> 首页</a></li>
        <li> 基础配置</li>
        <li class="active">轮播图片</li>
      </ol>
    </section>
<!--主体-->
    <!-- Main content -->
  <section class="content">
    <div class="box">
    <div class="box-header">
      <div class="box-tools">
        <a href="javascript:void(0)" data-toggle="modal" data-target="#aDdit">添加</a>
      </div>
    </div>
    <div class="box-body">
    <table class="table table-bordered" id="example1">
    	<thead>
              <tr>
                <th>ID</th>
                <th>标题</th>
                <th>类型</th>
                <th>添加时间</th>
                <th>图片</th>
                <th>状态</th>
                <th>排序</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
                <volist name="list" id="vo">
                <tr>
                <td>
                       {$vo.id}
                </td>
                 <td>
                       {$vo.title}
                </td>
                <td>
                       <if condition="$vo.type eq 0">
                           首页轮播
                       <elseif condition="$vo.type eq 1"/>
                       APP轮播
                       <else/>
                       </if>
                </td>
                <td>
                       {$vo.time|date="Y-m-d H:i:s",###}
                </td>
                <td>
                    <a href="__PUBLIC__/uploadify/uploads/undefined/{$vo.img}" class="cboxElement">
                        <img src="__PUBLIC__/uploadify/uploads/undefined/{$vo.img}" width="150" height="60">
                    </a>
                </td>
                <td class="form-group">
                    <if condition="$vo.state eq 0">
                   显示
                   <else />
					隐藏
                  </if>
                </td>
                <td  width="200">

                  <input name="order" type="text" value="{$vo.order}" class="form-control" onblur='var order=$(this).val();$.post("__APP__/TIFAWEB_DSWJCMS/Basis/savesh", { id: {$vo.id},order:order} );'/>
                </td>
                <td>
                    <a href="__APP__/TIFAWEB_DSWJCMS/Basis/editshu/{$vo.id}.html" class="fa fa-pencil text-light-blue" title="编辑" style="margin-right: 5px;"></a>&nbsp;&nbsp;
                    <a href="#" class="fa fa-trash text-red"title="删除" onclick="if(confirm('是否要删除？'))window.location.href='__APP__/TIFAWEB_DSWJCMS/Basis/delesh/{$vo.id}'"></a>
                </td>
              </tr>
			  <input name="id[]" type="hidden" value="{$vo.id}" />
</volist>
            </tbody>
     </table>
        
              
    </div>
    </div>
  </section>

<!--添加轮播图片 开始-->
<div class="modal fade" id="aDdit">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">添加轮播图片</h4>
      </div>
      <div class="modal-body">
		<form method="post"  action='__APP__/TIFAWEB_DSWJCMS/Basis/addsh'  enctype="multipart/form-data">
        <table class="table">
        	<tbody>
              <tr>
                <td>
                       标题：
                </td>
                <td>
                  <input name="title" type="text" class="form-control" placeholder="请输入标题...">
                </td>
              </tr>
              <tr>
                <td>
                       类型：
                </td>
                <td>
                    <select name="type" class="form-control">
                            <option value="0">首页轮播</option>
                            <option value="1">APP轮播</option>
                    </select>
                </td>
              </tr>
              <tr>
                <td>
                       图片：
                </td>
                <td>
                <div class="imgupload"  id="fileList"  style="width:202px;height:102px;">
                	<span class="fa fa-plus"></span>
                 </div>
                  <input name="input" type="file" id="fileElem" multiple accept="image/*"  onchange="handleFiles(this)" class="hide">
                 
                </td>
              </tr>
              <tr>
                <td>
                       链接地址：
                </td>
                <td>
                  <input name="url" type="text" class="form-control"  value="javascript:void(0)">
                </td>
              </tr>
              <tr>
                <td>
                       状态：
                </td>
                <td class="form-group">
                  <label><input class="minimal" type="radio" name="state" value="0" checked/> 显示</label>
                  <label><input class="minimal" type="radio" name="state" value="1" /> 隐藏</label>
                </td>
              </tr>
               <tr>
                <td>
                       排序：
                </td>
                <td>
                  <input name="order" type="text" class="form-control"  value="0">
                </td>
              </tr>
            </tbody>
        </table>
        	<div class="modal-footer">
            <button type="button" class="btn btn-default pull-left" data-dismiss="modal">取消</button>
            <button type="submit" class="btn btn-primary" >确认添加</button>
            
          </div>
      </form>
      </div>
      
      
    </div>
    <!-- /.modal-content -->
  </div>
  <!-- /.modal-dialog -->
</div>
<!--添加轮播图片 结束-->
<include file="Index:footer" />
<script>
//图片上传处理
window.URL = window.URL || window.webkitURL;
    var fileElem = document.getElementById("fileElem"),
    fileList = document.getElementById("fileList");
	fileList.addEventListener('click',function(){
		fileElem.click();
	},false);
    function handleFiles(obj) {
        var files = obj.files,
        img = new Image();
        if(window.URL){
            //File API
            //alert(files[0].name + "," + files[0].size + " bytes");
            img.src = window.URL.createObjectURL(files[0]); //创建一个object URL，并不是你的本地路径
            img.onload = function(e) {
                window.URL.revokeObjectURL(this.src); //图片加载后，释放object URL
            }
			
            fileList.innerHTML='<img src="'+img.src+'" style="width:200px;height:100px;"/>';
        }else if(window.FileReader){
            //opera不支持createObjectURL/revokeObjectURL方法。我们用FileReader对象来处理
            var reader = new FileReader();
            reader.readAsDataURL(files[0]);
            reader.onload = function(e){
               // alert(files[0].name + "," +e.total + " bytes");
                img.src = this.result;
                img.width = 200;
                 fileList.innerHTML='<img src="'+img.src+'"  style="width:200px;height:100px;"/>';
            }
        }else{
            //ie
            obj.select();
            obj.blur();
            var nfile = document.selection.createRange().text;
            document.selection.empty();
            img.src = nfile;
            img.width = 200;
            img.onload=function(){
                //alert(nfile+","+img.fileSize + " bytes");
            }
            fileList.innerHTML='<img src="'+img.src+'"  style="width:200px;height:100px;"/>';
        }
    }
$(function () {
    $('#example1').DataTable({
		language: {  
		  "sProcessing": "处理中...",  
		  "sLengthMenu": "显示 _MENU_ 项结果",  
		  "sZeroRecords": "没有匹配结果",  
		  "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",  
		  "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",  
		  "sInfoFiltered": "(由 _MAX_ 项结果过滤)",  
		  "sInfoPostFix": "",  
		  "sSearch": "搜索:",  
		  "sUrl": "",  
		  "sEmptyTable": "表中数据为空",  
		  "sLoadingRecords": "载入中...",  
		  "sInfoThousands": ",",  
		  "oPaginate": {  
			  "sFirst": "首页",  
			  "sPrevious": "上页",  
			  "sNext": "下页",  
			  "sLast": "末页"  
		  },  
		  "oAria": {  
			  "sSortAscending": ": 以升序排列此列",  
			  "sSortDescending": ": 以降序排列此列"  
		  }  
	  }  
	})
})	
</script>